package ouyangye;

class Goods {

    private String id;
    private String name;
    private double purchasePrice;
    private double sellingPrice;

    public Goods() {
    }

    public Goods(String id, String name, double purchasePrice, double sellingPrice) {
        this.id = id;
        this.name = name;
        this.purchasePrice = purchasePrice;
        this.sellingPrice = sellingPrice;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPurchasePrice() {
        return purchasePrice;
    }

    public void setPurchasePrice(double purchasePrice) {
        this.purchasePrice = purchasePrice;
    }

    public double getSellingPrice() {
        return sellingPrice;
    }

    public void setSellingPrice(double sellingPrice) {
        this.sellingPrice = sellingPrice;
    }

    // 其他方法：计算利润
    public double calculateProfit() {
        return sellingPrice - purchasePrice;
    }


    public String toString() {
        return "商品编号：" + id + "，商品名称：" + name + "，进价：" + purchasePrice + "，售价：" + sellingPrice;
    }
}

class Book extends Goods {

    private String author;

    public Book() {
    }

    public Book(String id, String name, double purchasePrice, double sellingPrice, String author) {
        super(id, name, purchasePrice, sellingPrice);
        this.author = author;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void showAuthor() {
        System.out.println("书籍作者：" + author);
    }


    public String toString() {
        return super.toString() + "，作者：" + author;
    }
}

public class test {
    public static void main(String[] args) {

        Book book = new Book("01", "Java", 30, 50, "张三");

        System.out.println(book);

        book.showAuthor();

        System.out.println("书籍利润：" + book.calculateProfit());
    }
}